package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

/** 集合转换为数组*/
public class CollecttionToArray {
    public static void main(String[] args) {
        Collection<String> a=new ArrayList<>();
        a.add("one");
        a.add("two");
        a.add("three");
        a.add("four");
        a.add("five");
        System.out.println(a);
        String[]array=a.toArray(new String[6]);
        System.out.println(Arrays.toString(array));
        String[]array1=a.toArray(new String[0]);
        System.out.println(Arrays.toString(array1));
    }
}
